﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DisplayBoardInfo.Server.Forms.CustomComponents.EntityList
{
    class UsersListModel : ListModel
    {
        IEnumerable<Entities.User> users;

        public UsersListModel(IEnumerable<Entities.User> users)
        {
            this.users = users;
        }

        public override string[] GetHeader()
        {
            return new string[]{ "Nazwa użytkownika", "Imię", "Nazwisko", "Rola" };
        }

        public override string[,] GetData()
        {
            string[,] output = new string[users.Count(), 4];

            int i = 0;
            foreach (Entities.User item in users)
            {
                output[i, 0] = item.Username;
                output[i, 1] = item.Name;
                output[i, 2] = item.LastName;
                output[i, 3] = item.Role.Name;
            }

            return output;
        }
    }
}
